/*!
 * Project's name: Ziemianie
 * Supervisor: mgr Tomasz Kornuta, Warsaw University of Technology
 * File's autors: Michal Plutecki, G1ISI, Warsaw University of Technology
 * Date: 3-12-2008
 * Description:
 * 	SCZR Coursework
 * 	Team: Jakub Rosiak, Michal Lisiecki, Michal Plutecki
 * 	Warsaw University of Technology
 * */

#ifndef DBCONNECTION_H_
#define DBCONNECTION_H_

#include <iostream>
#include <sstream>
#include <stdlib.h>
#include <string>
#include "../Komunikacja/Response.h"
#include "DBKlewki.h"
#include "../Komunikacja/Message.h"

/*!
 * \brief
 * Class used to operate on a database.
 * 
 * \see
 * DBKlewki
 */
class DBConnection
{
public:
	static DBConnection * GetInstance();
	virtual ~DBConnection();
	bool checkConnection();
	bool printDB();
	bool clearDB();
	bool initializeDB();
	
	Response * setRelationInDB(Message * msg);
	Response * dropRelationInDB(Message * msg);
	Response * getInfoFromDB(Message * msg);
	Response * addToDB(Message * msg);
	Response * takeFromDB(Message * msg);
	
private:
	std::string db_file_;
	DBKlewki * db_ptr_;
	static DBConnection * dbConnection_;
	
	DBConnection(std::string db_file);
	DBConnection();
	
	void connect();
	void disconnect();
};

#endif /*DBCONNECTION_H_*/
